﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;

namespace LitTools
{
    /// <summary>
    /// 物体过滤器
    /// 在物体列表中的物体可以通过
    /// </summary>
    public class GameObjectFilter : FilterBase
    {
        [Header("物体列表")]
        public List<GameObject> goList;

        public override List<RaycastResult> FiltResults(List<RaycastResult> result)
        {
            if (result == null)
                return null;
            if(goList==null
                || goList.Count == 0)
                return null;
            for (int i = 0; i < result.Count; i++)
            {
                if (!goList.Contains(result[i].gameObject))
                {
                    result.RemoveAt(i);
                    i--;
                }
            }
            return result;
        }
    }
}
